package com.chuangyang.fixboxmaster.ui;

import android.os.Build;
import android.os.Bundle;
import android.webkit.WebSettings;
import android.webkit.WebView;

import com.android.volley.Response;
import com.chuangyang.fixboxmaster.R;
import com.chuangyang.fixboxmaster.bean.OnlineServiceItem;
import com.chuangyang.fixboxmaster.service.FixBoxApi;
import com.chuangyang.fixboxmaster.service.GsonRequest;

import java.util.HashMap;

/**
 * Created by vanshu on 15/10/19 09:48.
 */
public class OnLineServiceActivity  extends BaseActivity{
    private WebView mWebView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setTitle("在线客服");
        setContentView(R.layout.activity_online);
        String orderId=getIntent().getStringExtra("orderId");
        HashMap<String, String> param = new HashMap<>();
        param.put("id", orderId);
        addRequest(new GsonRequest<>(FixBoxApi.B2B_ONLINE_SERVICE, param, OnlineServiceItem.class, responseListener));
        mWebView= (WebView) findViewById(R.id.online_service_webview);
        WebSettings webSettings = mWebView.getSettings();
        webSettings.setJavaScriptEnabled(true);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            WebView.setWebContentsDebuggingEnabled(true);
        }
    }


    private Response.Listener<OnlineServiceItem>  responseListener=new Response.Listener<OnlineServiceItem>(){
        @Override
        public void onResponse(OnlineServiceItem response) {
            mWebView.loadUrl(response.result);
        }
    };
}
